﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.Drawing.Text;

namespace RadarA
{
    public partial class UserControlhinhvuong : UserControl
    {
        Color _lineColor = Color.FromArgb(0, 255, 0);// vẽ màu đường quét
        int widthPictrueBox = 0;
        Graphics g = null;  // công cụ vẽ
        public UserControlhinhvuong()
        {
            InitializeComponent();
        }

        private void UserControlhinhvuong_Load(object sender, EventArgs e)
        {
            widthPictrueBox = pictureBox1.Width;
        }
        public void CreateBaseImage3()
        {
            // tao thuc the drawing
            Image i = new Bitmap(widthPictrueBox, widthPictrueBox);
            if (g != null)
            {
                g.Dispose();
            }
            else
            {
                g = Graphics.FromImage(i);
            }
            //Graphics g = Graphics.FromImage(i);
            Pen p = new Pen(_lineColor);
            //lam anh dep hon
            //g.CompositingQuality = CompositingQuality.HighQuality;
            //g.InterpolationMode = InterpolationMode.Bicubic;
            //g.SmoothingMode = SmoothingMode.AntiAlias;
            //g.TextRenderingHint = TextRenderingHint.AntiAlias;
            // ve anh nen cua anh radar scan

            g.DrawEllipse(p, 0, 0, widthPictrueBox - 1, widthPictrueBox - 1);
            // ve cac vong tron ( o day la 5 vong tron)
            int interval = widthPictrueBox / 3;
            Font ab = new Font("Arial", 10);
            for (int j = 1; j < 3; j++)
            {
                int interval1 = interval * j;
                g.DrawEllipse(p, (widthPictrueBox - interval1) / 2, (widthPictrueBox - interval1) / 2, interval1, interval1);
                if (j == 1)
                {
                    g.DrawString("180", ab, Brushes.Red, widthPictrueBox / 2, (widthPictrueBox / 3) - 15);
                }
                if (j == 2)
                {
                    g.DrawString("135", ab, Brushes.Red, widthPictrueBox / 2, (widthPictrueBox / 6) - 15);
                }
            }
            //ve12doan();
            Font abc = new Font("Arial", 10);

            g.DrawString("W", abc, Brushes.Red, 0, widthPictrueBox / 2);
            g.DrawString("N", abc, Brushes.Red, widthPictrueBox / 2, 0);
            g.DrawString("E", abc, Brushes.Red, widthPictrueBox - 15, widthPictrueBox / 2);
            g.DrawString("S", abc, Brushes.Red, widthPictrueBox / 2, widthPictrueBox - 15);
            // xoa anh ve
            //g.Dispose();
        }
    }
}
